/**
 * Event Broadcaster
 * 
 * this class provides an event broadcaster to add listener and fire events with
 * to listeners
 * 
 * @author flobo
 */
 var Broadcaster = new Class({
	listener:[],
	
	initialize:function() {
		
	},
	
	addListener:function(o) {
		this.listener.push(o);
	},
	
	removeListener:function(object, i) {
		var index = this.listener.indexOf(object);
		if(index) {
			this.listener.splice(index, 1);
		}
	},
	
	getListener:function() {
		this.listener.each(function(l) {
			console.log(l.name);
		});
	},
	
	broadcastMessage:function(func, param) {
		this.listener.each(function(e,i) {
			if(typeof e !== 'undefined') {
				if (typeof e[func] == "function") {
					e[func](param);
				}
				
				else if (typeof e.events == "function") {
					e.events(func, param);
				}
			}
		});
	}
});
